
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/7/23
  Time: 21:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<c:set var="resroot" value="${ctx}/common"/>
<html>
<head>
    <title>修改个人信息</title>

</head>
<body>
<form action="#">
  新用户名：&nbsp;<input type="text" name="userName" id="userName"><br>
  新密&nbsp;码：&nbsp;<input type="password" name="password" id="password"><br>
  新手机号码：<input type="text" name="phoneNum" id="phoneNum"><br>
  <button type="button" onclick="modify()" class="btn btn-primary btn-block btn-flat">修改</button>
</form>

<script src="${ctx}/common/js/jQuery-2.1.4.min.js"></script>
<script>
  function modify(){
    var userName = $("#userName").val().trim();
    var password = $("#password").val().trim();
    var phoneNum= $("#phoneNum").val().trim();
    if(!userName || !password || !phoneNum){
      alert("用户名、密码或手机号码不能为空");
      return;
    }
    if(password.length < 6){
      alert("密码不得少于6位数");
      return;
    }
    $.ajax({
      url:"${ctx}/modify.action",
      type: "POST",
      datatype:"json",
      data:{
        userName: userName,
        password: password,
        phoneNum: phoneNum
      },
      success:function(result){
        if(result.success) {
          location.href = '${ctx}/login.action';
        }else{
          alert(result.error);
        }
      }
    });
  }
</script>
</body>
</html>
